import request from '@/hooks/request'

const Api = {
  getfishProductList: '/fish/product/fishProductList', // 闲鱼商品列表
  setGoodsStatus: '/fish/product/editProductStatus', // 闲鱼商品上架或者下架
  synchronizationProduct: '/fish/product/synchronizationProduct',
  getSpBizType: '/fish/product/getSpBizType', // 获取行业
  getCategory: '/fish/product/getCategory', // 获取类目
  getChannel: '/fish/product/getChannel', // 获取渠道
  putawayProduct: '/fish/product/putawayProduct', // 发布商品
  EditawayProduct: '/fish/product/editProduct', // 编辑商品
  ProductDetail: '/fish/product/getProduct', // 商品详情
  batchEditProductStatus: '/fish/product/batchEditProductStatus', // 批量上下架
  batchProductChangePrice: '/fish/product/batchProductChangePrice', // 批量改价
  getIndustryList: '/fish/product/getIndustryList', // 所有行业、类目
  getFishGoodsList: '/fish/product/getFishProductGroup', //获取当前商品分组
  addFishGoodsGroup: '/fish/product/addFishProductGroup', //添加当前商品分组
  delFishGoodsGroup: '/fish/product/deleteFishProductGroup', //删除当前商品分组
  editFishProductGroup: '/fish/product/editFishProductGroup', //编辑当前 分组名称
  addGoodsInGroup: '/fish/product/fishProductAddGroup', //添加商品进分组
  fishProductExcelOut: '/fish/product/fishProductExcelOut', // 闲鱼商品列表导出

  timerPageList: '/fish/product/timerPageList', // 定时发布商品列表
  putawayTimerProduct: '/fish/product/putawayTimerProduct', // 定时发布商品
  updateTimerStatus: '/fish/product/updateTimerStatus', // 修改定时发布商品的状态
  updateFishTimerReleaseProduct: '/fish/product/updateFishTimerReleaseProduct', // 编辑定时发布商品
}

export const updateTimerStatus = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('id', parameter.id)
  formData.append('timerStatus', parameter.timerStatus)
  return request({
    method: 'post',
    url: Api.updateTimerStatus,
    data: formData,
  })
}

export const updateFishTimerReleaseProduct = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.updateFishTimerReleaseProduct,
    data: parameter,
  })
}

export const putawayTimerProduct = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.putawayTimerProduct,
    data: parameter,
  })
}


export const timerPageList =  (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.timerPageList,
    data: parameter
  })
}

export const fishProductExcelOut = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.fishProductExcelOut,
    data: parameter,
    responseType: 'blob',
  })
}

export const getIndustryList = () => {
  return request({
    method: 'post',
    url: Api.getIndustryList,
  })
}

export const getfishProductList = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.getfishProductList,
    data: parameter,
  })
}

export const setGoodsStatus = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.setGoodsStatus,
    data: parameter,
  })
}

export const synchronizationProduct = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('robotId', parameter.robotId)
  return request({
    method: 'post',
    url: Api.synchronizationProduct,
    data: formData,
  })
}

export const getSpBizType = () => {
  return request({
    method: 'post',
    url: Api.getSpBizType,
  })
}

export const getCategory = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('spBizTypeNum', parameter.spBizTypeNum)
  return request({
    method: 'post',
    url: Api.getCategory,
    data: formData,
  })
}

export const getChannel = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('categoryNum	', parameter.categoryNum)
  return request({
    method: 'post',
    url: Api.getChannel,
    data: formData,
  })
}

export const putawayProduct = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.putawayProduct,
    data: parameter,
  })
}

export const EditawayProduct = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.EditawayProduct,
    data: parameter,
  })
}

export const getProductDetail = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('id	', parameter.id)
  return request({
    method: 'post',
    url: Api.ProductDetail,
    data: formData,
  })
}

export const batchProductChangePrice = (parameter: Record<any, any>) => {
  // const formData = new FormData()
  // formData.append('productIds', parameter.productIds)
  // formData.append('originalPrice', parameter.originalPrice)
  // formData.append('sellingPrice', parameter.sellingPrice)
  // formData.append('transportFee', parameter.transportFee)
  return request({
    method: 'post',
    url: Api.batchProductChangePrice,
    data: parameter,
  })
}

export const batchEditProductStatus = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.batchEditProductStatus,
    data: parameter,
  })
}
export const getFishGoodsList = () => {
  return request({
    method: 'post',
    url: Api.getFishGoodsList,
    // data: parameter,
  })
}

export const addFishGoodsGroup = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.addFishGoodsGroup,
    data: parameter,
  })
}

export const delFishGoodsGroup = (parameter: Record<any, any>) => {
  const formData = new FormData()
  formData.append('id	', parameter.id)

  return request({
    method: 'post',
    url: Api.delFishGoodsGroup,
    data: formData,
  })
}

export const editFishGoodsGroup = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.editFishProductGroup,
    data: parameter,
  })
}

export const submitGoodsInGroup = (parameter: Record<any, any>) => {
  return request({
    method: 'post',
    url: Api.addGoodsInGroup,
    data: parameter,
  })
}
